# -*- coding: utf-8 -*-

# @File  : score_ten.py
# @Author: Lomo
# @Site  : lomo.space
# @Date  : 2019-11-28
# @Desc  : 计算十分制


from model.supplier_star import SupplierStar


# 销售额
def score_ten_sell(date):
    supplier_star = SupplierStar()
    current_date_scores = supplier_star.get_suppliers_by_date(date=date)
    current_date_max = supplier_star.get_max_index_by_date('sell', date)[0]
    current_date_min = supplier_star.get_min_index_by_date('sell', date)[0]

    for obj in current_date_scores:
        # print('供应商 ID: {0}, sell: {1}'.format(obj[1], obj[25]))
        current_sell = obj[25]
        this_ten_score = (current_sell - current_date_min) / (current_date_max -
                                                              current_date_min)
        this_ten_score *= 10

        print('供应商 ID: {0}, 起始sell值: {1}, 十分制值: {2}'.format(obj[1], obj[25],
                                                            this_ten_score))
    print('{0} 销售额 sell 情况, 总计商家{1}个, sell 最大值 {2}、 最小值 {3}'.format(date, len(current_date_scores),
                                                                  current_date_max, current_date_min))


# sell_operate, 经营利润率
def sell_operate_ten(date):
    supplier_star = SupplierStar()
    current_date_scores = supplier_star.get_suppliers_by_date(date=date)
    current_date_max = supplier_star.get_max_index_by_date('sell_operate', date)[0]
    current_date_min = supplier_star.get_min_index_by_date('sell_operate', date)[0]

    for obj in current_date_scores:
        current_sell = obj[28]
        this_ten_score = (current_sell - current_date_min) / (current_date_max -
                                                              current_date_min)
        this_ten_score *= 10

        print('供应商 ID: {0}, 起始经营利润率值: {1}, 十分制值: {2}'.format(obj[1], obj[28],
                                                            this_ten_score))
